#include <stdio.h>
int WordsCount(char list[])
{
	int inWord = 0, count = 0;
	//	inWord, 0:不处于单词中，1:处于单词当中
	for (int i = 0; list[i] != '\0'; i++)
	{
		if (list[i] == ' ')
			inWord = 0;
		else 
			if (inWord == 0)
			{
				inWord = 1;
				count++;
			}
	}
	return (count);
}

int main ( )
{
	char inputString [1000] ;
	int wordCount ;
	printf ( "\n请输入字符串（只包括单词和空格）\n" );
	gets (inputString);
	wordCount = WordsCount (inputString) ;
	printf ( "单词有%d个\n", wordCount) ;
	return 0;
}

